package com.lungle.warmdiary.app.view.message.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.lungle.warmdiary.R;
import com.lungle.warmdiary.app.base.BaseFragment;
import com.lungle.warmdiary.app.model.response.Message;
import com.umeng.analytics.MobclickAgent;

import butterknife.Bind;
import butterknife.ButterKnife;


public class MessageDetailFragment extends BaseFragment implements View.OnClickListener {
    private static final String MESSAGE_DETAIL_SCREEN = "message dtail screen";

    public static final String ARGS_MESSAGE = "message_model";
    @Bind(R.id.tv_active_title)
    TextView mTvTitle;
    @Bind(R.id.tv_active_time)
    TextView mTvTime;
    @Bind(R.id.tv_message_content)
    TextView mTvContent;
    @Bind(R.id.btn_view)
    Button mBtnView;
    private Message mMessage;



    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_message_detail, container, false);
        mMessage = (Message) getActivity().getIntent().getSerializableExtra(ARGS_MESSAGE);
        ButterKnife.bind(this, view);
        initData();
        initView(view);
        return view;
    }

    @Override
    public void initView(View view) {
        mBtnView.setOnClickListener(this);
    }

    @Override
    public void initData() {
        mTvTitle.setText(mMessage.getTitle());// TODO: 2016/8/24
        mTvTime.setText(String.format("时间: %s", mMessage.getCreatetime()


        ));
        mTvContent.setText(mMessage.getContent());
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart(MESSAGE_DETAIL_SCREEN);
        MobclickAgent.onResume(getActivity());

    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd(MESSAGE_DETAIL_SCREEN);
        MobclickAgent.onPause(getActivity());

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }


    public void onClick(View v) {
        int id = v.getId();
        detail(mMessage.getLink());
    }

    // TODO: 2016/8/14  
    private void detail(String deeplink) {
    }
}
